<template>
    <el-form-item label="投放日期范围" :prop="`delivery.delivery_time`" :rules="{required: true, message: '请选择', trigger: ['blur', 'change']}">
        <el-date-picker v-model="createform.delivery.delivery_time" @change="selectSeliverytime" type="daterange" range-separator="~" value-format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期" size="small" :picker-options="pickerOptions">
        </el-date-picker>
    </el-form-item>
</template>

<script>
export default {
    props: ["createform"],
    name: "",
    data() {
        return {
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() < Date.now() - 8.64e7; //如果没有后面的-8.64e7就是不可以选择今天的
                },
            },
        };
    },
    created() {},
    methods: {
        //选择投放日期范围
        selectSeliverytime() {
            if (this.createform.delivery.delivery_time !== null) {
                this.createform.delivery.start_time =
                    this.createform.delivery.delivery_time[0];
                this.createform.delivery.end_time =
                    this.createform.delivery.delivery_time[1];
            }
            this.sessionSave();
        },

        sessionSave() {
            this.$emit("sessionSave");
        },
    },
    components: {},
};
</script>


<style scoped>
</style>

